﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace PrototiposHP
{
    public partial class frmGenerarAgendaTurnos : Form
    {
        public frmGenerarAgendaTurnos()
        {
            InitializeComponent();
            cargarGrilla();
        }

        private void cargarGrilla()
        {
            DateTime horaInicio = new DateTime(2014, 01, 01, 08, 00, 00);
            TimeSpan duracionTurno = new TimeSpan(0, 30, 0);
            int index = 0;
            while (true)
            {
                grdAgenda.Rows.Add();
                if (index == 0)
                    grdAgenda.Rows[index].Cells[0].Value = horaInicio.ToShortTimeString();
                else
                {
                    horaInicio = horaInicio + duracionTurno;
                    grdAgenda.Rows[index].Cells[0].Value = horaInicio.ToShortTimeString();
                }
                if (horaInicio.Hour < 17)
                    index++;
                else
                    break;
            }
            int cantFilas = grdAgenda.RowCount;
            grdAgenda.RowsDefaultCellStyle.BackColor = Color.LightGray;  //por defecto todo es No disponible

            for (int i = 0; i < cantFilas; i++) //cargamos las celdas Disponibles y seteamos que la primera columna, la de las horas, no sea editable y tenga otro color
            {
                grdAgenda.Rows[i].Cells[0].Style.BackColor = Color.DimGray; //celdas de hora
                grdAgenda.Rows[i].Cells[0].Style.ForeColor = Color.White;
                grdAgenda.Rows[i].Cells[0].ReadOnly = true;

                grdAgenda.Rows[i].Cells[2].Style.BackColor = Color.White;
                if (i > 2 && i < 12)
                    grdAgenda.Rows[i].Cells[4].Style.BackColor = Color.White;
            }

        }
    }
}
